<?php echo $header; ?>
<div id="content">
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  <?php if ($error_warning) { ?>
  <div class="warning"><?php echo $error_warning; ?></div>
  <?php } ?>
  <?php if ($success) { ?>
  <div class="success"><?php echo $success; ?></div>
  <?php } ?>
  <div class="box">
    <div class="heading">
      <h1><img src="view/image/report.png" alt="" /> <?php echo $heading_title; ?></h1>
      <div class="buttons"><a onclick="$('#form').attr('action', '<?php echo $delete; ?>'); $('#form').attr('target', '_self'); $('#form').submit();" class="button"><span><?php echo $button_delete; ?></span></a></div>
    </div>
    <div class="content">
      <form action="" method="post" enctype="multipart/form-data" id="form">
        <table class="list">
          <thead>
            <tr>
              <td width="1" style="text-align: center;"><input type="checkbox" onclick="$('input[name*=\'selected\']').attr('checked', this.checked);" /></td>
              <td class="right"><?php if ($sort == 'o.answer_id') { ?>
                <a href="<?php echo $sort_answer; ?>" class="<?php echo strtolower($answer); ?>"><?php echo $column_answer_id; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_answer; ?>"><?php echo $column_answer_id; ?></a>
                <?php } ?></td>
			  <td class="right"><?php if ($sort == 'o.survey_id') { ?>
                <a href="<?php echo $sort_survey; ?>" class="<?php echo strtolower($survey); ?>"><?php echo $column_survey_id; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_survey; ?>"><?php echo $column_survey_id; ?></a>
                <?php } ?></td>
			  <td class="right"><?php if ($sort == 'o.question_id') { ?>
                <a href="<?php echo $sort_question; ?>" class="<?php echo strtolower($question); ?>"><?php echo $column_question_id; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_question; ?>"><?php echo $column_question_id; ?></a>
                <?php } ?></td>
              <td class="left"><?php if ($sort == 'customer') { ?>
                <a href="<?php echo $sort_customer; ?>" class="<?php echo strtolower($answer); ?>"><?php echo $column_customer; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_customer; ?>"><?php echo $column_customer; ?></a>
                <?php } ?></td>
			  <td class="left"><?php if ($sort == 'email') { ?>
                <a href="<?php echo $sort_email; ?>" class="<?php echo strtolower($answer); ?>"><?php echo $column_email; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_email; ?>"><?php echo $column_email; ?></a>
                <?php } ?></td>
              <td class="left"><?php if ($sort == 'o.date_added') { ?>
                <a href="<?php echo $sort_date_added; ?>" class="<?php echo strtolower($answer); ?>"><?php echo $column_date_added; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_date_added; ?>"><?php echo $column_date_added; ?></a>
                <?php } ?></td>
              <td class="left"><?php if ($sort == 'o.date_modified') { ?>
                <a href="<?php echo $sort_date_modified; ?>" class="<?php echo strtolower($answer); ?>"><?php echo $column_date_modified; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_date_modified; ?>"><?php echo $column_date_modified; ?></a>
                <?php } ?></td>
              <td class="right"><?php echo $column_action; ?></td>
            </tr>
          </thead>
          <tbody>
            <tr class="filter">
              <td></td>
              <td align="right"><input type="text" name="filter_answer_id" value="<?php echo $filter_answer_id; ?>" size="4" style="text-align: right;" /></td>
              <td align="right"><input type="text" name="filter_survey_id" value="<?php echo $filter_survey_id; ?>" size="4" style="text-align: right;" /></td>
              <td align="right"><input type="text" name="filter_question_id" value="<?php echo $filter_question_id; ?>" size="4" style="text-align: right;" /></td>
              <td><input type="text" name="filter_customer" value="<?php echo $filter_customer; ?>" /></td>
			  <td><input type="text" name="filter_email" value="<?php echo $filter_email; ?>" /></td>
              <td><input type="text" name="filter_date_added" value="<?php echo $filter_date_added; ?>" size="12" class="date" /></td>
              <td><input type="text" name="filter_date_modified" value="<?php echo $filter_date_modified; ?>" size="12" class="date" /></td>
              <td align="right"><a onclick="filter();" class="button"><span><?php echo $button_filter; ?></span></a></td>
            </tr>
            <?php if ($answers) { ?>
            <?php foreach ($answers as $answer) { ?>
            <tr>
              <td style="text-align: center;"><?php if ($answer['selected']) { ?>
                <input type="checkbox" name="selected[]" value="<?php echo $answer['answer_id']; ?>" checked="checked" />
                <?php } else { ?>
                <input type="checkbox" name="selected[]" value="<?php echo $answer['answer_id']; ?>" />
                <?php } ?></td>
              <td class="right"><?php echo $answer['answer_id']; ?></td>
              <td class="right"><?php echo $answer['survey_id']; ?></td>
              <td class="right"><?php echo $answer['question_id']; ?></td>
              <td class="left"><?php echo $answer['customer']; ?></td>
              <td class="left"><?php echo $answer['email']; ?></td>
              <td class="left"><?php echo $answer['date_added']; ?></td>
              <td class="left"><?php echo $answer['date_modified']; ?></td>
              <td class="right"><?php foreach ($answer['action'] as $action) { ?>
                [ <a href="<?php echo $action['href']; ?>"><?php echo $action['text']; ?></a> ]
                <?php } ?></td>
            </tr>
            <?php } ?>
            <?php } else { ?>
            <tr>
              <td class="center" colspan="8"><?php echo $text_no_results; ?></td>
            </tr>
            <?php } ?>
          </tbody>
        </table>
      </form>
      <div class="pagination"><?php echo $pagination; ?></div>
    </div>
  </div>
</div>
<script type="text/javascript"><!--
function filter() {
	url = 'index.php?route=survey/answer&token=<?php echo $token; ?>';
	
	var filter_answer_id = $('input[name=\'filter_answer_id\']').attr('value');
	
	if (filter_answer_id) {
		url += '&filter_answer_id=' + encodeURIComponent(filter_answer_id);
	}
	
	var filter_survey_id = $('input[name=\'filter_survey_id\']').attr('value');
	
	if (filter_survey_id) {
		url += '&filter_survey_id=' + encodeURIComponent(filter_survey_id);
	}
	
	var filter_question_id = $('input[name=\'filter_question_id\']').attr('value');
	
	if (filter_question_id) {
		url += '&filter_question_id=' + encodeURIComponent(filter_question_id);
	}
	
	var filter_customer = $('input[name=\'filter_customer\']').attr('value');
	
	if (filter_customer) {
		url += '&filter_customer=' + encodeURIComponent(filter_customer);
	}
	
	var filter_email = $('input[name=\'filter_email\']').attr('value');
	
	if (filter_email) {
		url += '&filter_email=' + encodeURIComponent(filter_email);
	}
	
	var filter_date_added = $('input[name=\'filter_date_added\']').attr('value');
	
	if (filter_date_added) {
		url += '&filter_date_added=' + encodeURIComponent(filter_date_added);
	}
	
	var filter_date_modified = $('input[name=\'filter_date_modified\']').attr('value');
	
	if (filter_date_modified) {
		url += '&filter_date_modified=' + encodeURIComponent(filter_date_modified);
	}
				
	location = url;
}
//--></script>  
<script type="text/javascript"><!--
$(document).ready(function() {
	$('.date').datepicker({dateFormat: 'yy-mm-dd'});
});
//--></script> 
<script type="text/javascript"><!--
$('#form input').keydown(function(e) {
	if (e.keyCode == 13) {
		filter();
	}
});
//--></script> 
<?php echo $footer; ?>